package com.transaction.simulate.mapper;


import com.transaction.common.base.PageInfo;
import com.transaction.simulate.model.dto.Account;
import com.transaction.simulate.model.dto.AccountStatus;
import com.transaction.simulate.model.dto.ChannelAccount;
import com.transaction.simulate.model.dto.County;
import com.transaction.simulate.model.vo.ChannelAccountVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface AccountMapper {

    @Select("SELECT * FROM t_county ORDER BY RAND() LIMIT 1 ")
    County getRandomCounty();

    void batchInsertAccount(@Param("accountList") List<Account> accountList);

    void batchInsertChannelAccount(@Param("channelAccounts") List<ChannelAccount> channelAccounts);

    List<Account> getAccount(@Param("account") Account account, @Param("pageInfo") PageInfo pageInfo);

    List<ChannelAccount> getChannelAccount(@Param("channelAccount") ChannelAccount channelAccount,
                                           @Param("pageInfo")PageInfo pageInfo);

    List<Map<String, Object>> getAccountToMap(@Param("channelCode") String channelCode,
                                              @Param("dateRange") List<String> dateRange);

    void updateChannelAccount(@Param("channelCode") String channelCode,
                              @Param("dataList") List<Map<String, Object>> dataList);

    void insertChannelAccount(@Param("channelCode") String channelCode,
                              @Param("dataList") List<Map<String, Object>> dataList);

    void deleteChannelAccount(@Param("channelCode") String channelCode,
                              @Param("dataList") List<Map<String, Object>> dataList);

    List<ChannelAccountVo> getChannelAccountAvailable(@Param("channelAccountVo") ChannelAccountVo channelAccount,
                                                           @Param("page") PageInfo pageInfo);

    @Update("truncate table t_account")
    void deleteAll();

    @Update("truncate table t_channelAccount")
    void deleteChannelAccountAll();

    void insertAccountStatus(@Param("channelCode") String channelCode,
                             @Param("account") Map<String, Object> account);

    void updateAccountStatus(@Param("channelCode") String channelCode,
                             @Param("dataList") List<Map<String, Object>> dataList);

    List<AccountStatus> getAccountStatus(AccountStatus accountStatus);

    void deleteAllAccountStatus(AccountStatus accountStatus);
}
